import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class SmsService extends BaseService<any> {
  private readonly logger = new Logger(SmsService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getList
   * 对应 PHP: SmsService_admin::getList()
   * 逻辑类型: undefined - undefined
   */
  async getList() {
    // 基于PHP真实逻辑: getList
    // PHP原文: $sms_type_list = SmsDict::getType();         $info = (new CoreConfigService())->getConfig($this->site_id, ConfigKeyDict::SMS);         if(empty($info)...
const sms_type_list = SmsDict.getType(];
        const info = this.coreConfigService.getConfig(this.site_id, ConfigKeyDict.SMS);
        if(!info) || !typeof info.value.default))
        {
            const config_type = [default: ''];//初始化
  }

  /**
   * getConfig
   * 对应 PHP: SmsService_admin::getConfig()
   * 逻辑类型: undefined - undefined
   */
  async getConfig(sms_type: string) {
    // 基于PHP真实逻辑: getConfig
    // PHP原文: $sms_type_list = SmsDict::getType();         if(!array_key_exists($sms_type, $sms_type_list)) throw new AdminException('SMS_TYPE_NOT_EXIST');         ...
const sms_type_list = SmsDict.getType(];
        if(!array_key_exists(sms_type, sms_type_list)) throw new AdminBusinessException('SMS_TYPE_NOT_EXIST'];
        const info = this.coreConfigService.getConfig(this.site_id, ConfigKeyDict.SMS);
        if(!info) || !typeof info.value.default))
        {
            const config_type = [default: ''];//初始化
  }

  /**
   * setConfig
   * 对应 PHP: SmsService_admin::setConfig()
   * 逻辑类型: undefined - undefined
   */
  async setConfig(sms_type: any[], data: any[]) {
    // 基于PHP真实逻辑: setConfig
    // PHP原文: $sms_type_list = SmsDict::getType();         if(!array_key_exists($sms_type, $sms_type_list)) throw new AdminException('SMS_TYPE_NOT_EXIST');         ...
const sms_type_list = SmsDict.getType(];
        if(!array_key_exists(sms_type, sms_type_list)) throw new AdminBusinessException('SMS_TYPE_NOT_EXIST'];
        const info = this.coreConfigService.getConfig(this.site_id, ConfigKeyDict.SMS);
        if(!info) || !typeof info.value.default))
        {
            config.default = '';
  }
}
